import Vue from 'vue'
import Router from 'vue-router'

import Main from '../views/Main'
import Login from '../views/Login'

import UserAdd from '../views/user/Add'
import UserList from '../views/user/List'

import NotFoundPage from '../views/404'


Vue.use(Router);

export default new Router({
  mode : 'history',  //history：路径不带 # ; hash：路径带 # 默认为hash
  routes : [
    // 登录页
    {
      name : "Login",
      path : "/login",
      component : Login
    },
    //首页
    {
      name : "Main",
      path : "/main",
      component : Main,
      children :[
        {name : "UserAdd" , path : "/user/add/:id" , component : UserAdd},
        {name : "UserAdd" , path : "/user/add" , component : UserAdd},
        {name : "UserList" , path : "/user/list/:id" , component : UserList , props:true}
      ]
    },
    // redirect : 重定向
    {
      path : "/",
      redirect: '/login'
    },

    //404页面
    {
      path : '*' ,
      component : NotFoundPage
    }
  ]
})
